import {
	defineStore
} from 'pinia'
import {
	getSubsidyDataApi,
	getSubsidyListApi
} from '@/pagesG/api/subsidy.js'

export const useSubsidyStore = defineStore('subsidy', {
	state: () => {
		return {
			lastMonthSettleAmt: 0, // 上月结算
			monthWaitSettleAmt: 0, // 本月待结算
			subsidyAmt: 0, // 补贴账户余额
			waitRechargeAmt: 0 // 待充值
		}
	},
	actions: {
		async getInfo() {
			const res = await getSubsidyDataApi()
			this.lastMonthSettleAmt = res.lastMonthSettleAmt
			this.monthWaitSettleAmt = res.monthWaitSettleAmt
			this.subsidyAmt = res.subsidyAmt
			this.waitRechargeAmt = res.waitRechargeAmt
			return res
		},
		// 获取补贴金资金明细
		async getSubsidyList(params) {
			const res = await getSubsidyListApi(params)
			return res
		}
	}
})